home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Think Class Libraries / CAccordionPane 1.0 / CAccordionPaneDemoDir.c < prev    next >
Encoding:
Text File  |  1994-11-30  |  3.0 KB  |  165 lines  |  [TEXT/KAHL]

  1. /******************************************************************************
  2.  CAccordionPaneDemoDir.c
  3.     
  4.     To install this Showcase demo, follow these two easy steps:
  5.     
  6.         1)  Add these source files to the CSApplication project.
  7.         
  8.             *     CAccordionPane
  9.                 CAccordionPaneDemoDir
  10.                 Parser.c
  11.             
  12.             [ Those marked with an * are the files necessary when using
  13.               the CAccordionPane class.  The others are only for this demo. ]
  14.     
  15.         2)    Add all resources in "CAccordionPaneDemo.rsrc" to the
  16.             Showcase resource file "CSApplication π.rsrc".
  17.  
  18.         3) Recompile and run.
  19.  
  20.     SUPERCLASS: CShowcaseDemoDir    
  21.     REQUIRES: CAccordionPane    
  22.     AUTHOR: Andrew_Gilmartin@Brown.Edu
  23.     MODIFIED: 93-03-05
  24.  
  25. ******************************************************************************/
  26.  
  27.  
  28. //#include <TCLHeaders>
  29. //#include "config.h"
  30. #include "CAccordionPaneDemoDir.h"
  31. #include "Parser.h"
  32.  
  33. char* gPaneStructure[] = {
  34.  
  35.         /* 3 panes vertically */
  36.         
  37.     "V 1 \
  38.         E 1 \
  39.         E 1 \
  40.         E 2 .",
  41.     
  42.         /* 3 panes horizontally */
  43.         
  44.     "H 1 \
  45.         E 1 \
  46.         E 2 \
  47.         E 1 .",
  48.  
  49.         /* 2 x 2 grid of panes */
  50.         
  51.     "V 1 \
  52.         H 1 \
  53.             E 1 \
  54.             E 1 \
  55.         . \
  56.         H 1 \
  57.             E 1 \
  58.             E 1 \
  59.         . \
  60.     . ",
  61.  
  62.         /* A Smalltalk-ish browser */
  63.         
  64.     "V 1 \
  65.         H 1 \
  66.             E 1 \
  67.             E 1 \
  68.             E 1 \
  69.         . \
  70.         E 2 \
  71.     .",
  72.     
  73.         /* 3 x 3 grid of panes */
  74.         
  75.     "V 1 \
  76.         H 1 \
  77.             F 75 \
  78.             E 1 \
  79.             E 1 \
  80.         . \
  81.         H 1 \
  82.             E 2 \
  83.             E 1 \
  84.             E 2 \
  85.         . \
  86.         H 1 \
  87.             E 1 \
  88.             E 1 \
  89.             F 75 \
  90.         . \
  91.     . ",
  92.  
  93. };
  94.  
  95. #define gPaneStructureCount ( sizeof( gPaneStructure ) / sizeof( char* ) )
  96.  
  97.  
  98. /******************************************************************************
  99.  INewDemo
  100.  
  101. ******************************************************************************/
  102.  
  103. #define kMargin 16
  104.  
  105. void CAccordionPaneDemoDir::INewDemo( CDirectorOwner *aSupervisor )
  106. {
  107.     CSizeBox* theSizeBox;
  108.     LongRect theInterior;
  109.     CPane* thePane;
  110.     CPaneBorder* theBorder;
  111.     Rect kBorderMargin = { 0, 0, 0, 0 };
  112.     static int whichStructure = 0;    
  113.     
  114.     SetCursor( *gWatchCursor );
  115.     
  116.     inherited::INewDemo( aSupervisor );
  117.  
  118.     itsWindow = new CWindow;
  119.     itsWindow->IWindow( 128, FALSE, gDesktop, this );
  120.  
  121.     theSizeBox = new CSizeBox;
  122.     theSizeBox->ISizeBox( itsWindow, aSupervisor );
  123.  
  124.         /*
  125.             Put the panes inside a bordered pane. 
  126.             This way we can "see" all the edges.
  127.         */
  128.         
  129.     itsWindow->GetInterior( &theInterior );
  130.     
  131.     thePane = new CPane;
  132.     thePane->IPane
  133.         ( itsWindow
  134.         , itsWindow->itsSupervisor
  135.         , theInterior.right - ( kMargin * 2 )
  136.         , theInterior.bottom - ( kMargin * 2 )
  137.         , kMargin
  138.         , kMargin
  139.         , sizELASTIC, sizELASTIC );
  140.     thePane->SetWantsClicks( TRUE );
  141.  
  142.     theBorder = new CPaneBorder;
  143.     theBorder->IPaneBorder( kBorderFrame );
  144.     theBorder->SetMargin( &kBorderMargin );
  145.     theBorder->SetPattern( gray );
  146.     thePane->SetBorder( theBorder );
  147.     
  148.         /*
  149.             Make the panes. 
  150.         
  151.             NOTE: there are N pane arrangements encoded. Each call to
  152.             INewDemo() makes the next in sequence.
  153.         */
  154.         
  155.     MakePanes
  156.         ( thePane
  157.         , gPaneStructure[ whichStructure++ % gPaneStructureCount ] );
  158.     
  159.         /* Show the window */
  160.     
  161.     gDecorator->StaggerWindow( itsWindow );
  162.     itsWindow->Select();
  163.     
  164. } /* INewDemo */
  165.